//
//  VectorShapeViewController.m
//  CoreAnimation
//
//  Created by 张国文 on 16/11/1.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "VectorShapeViewController.h"
#import "DrawingBoardView.h"
#import "UseCAShapeLayerOnDrawingBoardView.h"

@interface VectorShapeViewController ()

@end

@implementation VectorShapeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIButton *coreGraphics = [UIButton buttonWithType:UIButtonTypeCustom];
    coreGraphics.frame = CGRectMake(0, 100, 375, 30);
    coreGraphics.backgroundColor = [UIColor cyanColor];
    [coreGraphics setTitle:@"CoreGraphics画图" forState:UIControlStateNormal];
    [coreGraphics setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [coreGraphics addTarget:self action:@selector(coreGraphics:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:coreGraphics];
    
    UIButton *caShapeLayer = [UIButton buttonWithType:UIButtonTypeCustom];
    caShapeLayer.frame = CGRectMake(0, 200, 375, 30);
    caShapeLayer.backgroundColor = [UIColor cyanColor];
    [caShapeLayer setTitle:@"CAShapeLayer画图" forState:UIControlStateNormal];
    [caShapeLayer setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [caShapeLayer addTarget:self action:@selector(caShapeLayer:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:caShapeLayer];
}

- (void)coreGraphics:(UIButton *)button
{
    for (int i = 0; i < self.view.subviews.count; i++) {
        if ([self.view.subviews[i] isKindOfClass:[UIView class]]) {
            [self.view.subviews[i] removeFromSuperview];
        }
    }
    DrawingBoardView *drawV = [[DrawingBoardView alloc] initWithFrame:self.view.frame];
    drawV.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:drawV];
}

- (void)caShapeLayer:(UIButton *)button
{
    for (int i = 0; i < self.view.subviews.count; i++) {
        if ([self.view.subviews[i] isKindOfClass:[UIView class]]) {
            [self.view.subviews[i] removeFromSuperview];
        }
    }
    UseCAShapeLayerOnDrawingBoardView *useShapeOnDrawV = [[UseCAShapeLayerOnDrawingBoardView alloc] initWithFrame:self.view.frame];
    useShapeOnDrawV.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:useShapeOnDrawV];
}


@end
